var layer;
var load;
layui.use("layer",function(){
     layer=layui.layer;
})

/**
 * 普通ajax请求
 * @param url
 * @param type
 * @param dataType
 * @param param
 * @param $success
 */
function  requestAjax(url,type,dataType,param,$success) {

    $.ajax({
        url:url,
        type:type,
        dataType: dataType,
        data: param,
        beforeSend: function(){
            load=layer.load();
        },
        success:$success,
        error: function(jqxhr){
            layer.msg(jqxhr.status);
        },
        complete: function(){
            layer.close(load);
        }
    });
}

/**
 * 表单ajax 监控表单提交
 * @param formid
 * @param url
 * @param type
 * @param dataType
 * @param $success
 */
function requestAjaxForm(formid,url,type,dataType,$success){
    $("#"+formid).ajaxForm({
        url:url,
        type:type,
        dataType: dataType,
        beforeSend: function(){
            load=layer.load();
        },
        success:$success,
        error: function(jqxhr){
            layer.msg(jqxhr.status);
        },
        complete: function(){
            layer.close(load);
        }
    });
}